<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Random Number Generators - ClueLib</title><link rel="stylesheet" type="text/css" href="../styles/main.css"><script language=JavaScript src="../javascript/main.js"></script><script language=JavaScript src="../javascript/prettify.js"></script></head><body class="FramedContentPage" onLoad="NDOnLoad();prettyPrint();"><script language=JavaScript><!--
if (browserType) {document.write("<div class=" + browserType + ">");if (browserVer) {document.write("<div class=" + browserVer + ">"); }}// --></script>

<!--  Generated by Natural Docs, version 1.52 -->
<!--  http://www.naturaldocs.org  -->

<!-- saved from url=(0026)http://www.naturaldocs.org -->




<div id=Content><div class="CSection"><div class=CTopic id=MainTopic><h1 class=CTitle><a name="Random_Number_Generators"></a>Random Number Generators</h1><div class=CBody><!--START_ND_SUMMARY--><div class=Summary><div class=STitle>Summary</div><div class=SBorder><table border=0 cellspacing=0 cellpadding=0 class=STable><tr class="SMain"><td class=SEntry><a href="#Random_Number_Generators" >Random Number Generators</a></td><td class=SDescription></td></tr><tr class="SGroup SIndent1"><td class=SEntry><a href="#Types" >Types</a></td><td class=SDescription></td></tr><tr class="SType SIndent2 SMarked"><td class=SEntry><a href="#dist_bin" id=link1 onMouseOver="ShowTip(event, 'tt1', 'link1')" onMouseOut="HideTip('tt1')">dist_bin</a></td><td class=SDescription>Defines the structure of a random distribution bin.</td></tr><tr class="SClass"><td class=SEntry><a href="#random_util" id=link2 onMouseOver="ShowTip(event, 'tt2', 'link2')" onMouseOut="HideTip('tt2')">random_util</a></td><td class=SDescription>Provides a utility function to generate random numbers.</td></tr><tr class="SGroup SIndent1"><td class=SEntry><a href="#random_util.Functions" >Functions</a></td><td class=SDescription></td></tr><tr class="SFunction SIndent2 SMarked"><td class=SEntry><a href="#random_util.random_bool" id=link3 onMouseOver="ShowTip(event, 'tt3', 'link3')" onMouseOut="HideTip('tt3')">random_bool</a></td><td class=SDescription><span class="static">static</span> Returns a randomized Boolean value based on the specified percentage.</td></tr><tr class="SClass"><td class=SEntry><a href="#random_2_bin_num" id=link4 onMouseOver="ShowTip(event, 'tt4', 'link4')" onMouseOut="HideTip('tt4')">random_2_bin_num</a></td><td class=SDescription>Provides a random number using two distribution bins.</td></tr><tr class="SGroup SIndent1"><td class=SEntry><a href="#random_2_bin_num.Properties" >Properties</a></td><td class=SDescription></td></tr><tr class="SProperty SIndent2 SMarked"><td class=SEntry><a href="#random_2_bin_num.db" id=link5 onMouseOver="ShowTip(event, 'tt5', 'link5')" onMouseOut="HideTip('tt5')">db</a></td><td class=SDescription>Random distribution bins. </td></tr><tr class="SProperty SIndent2"><td class=SEntry><a href="#random_2_bin_num.val" id=link6 onMouseOver="ShowTip(event, 'tt6', 'link6')" onMouseOut="HideTip('tt6')">val</a></td><td class=SDescription><span class="rand">rand</span> The randomized value.</td></tr><tr class="SGroup SIndent1"><td class=SEntry><a href="#random_2_bin_num.Functions" >Functions</a></td><td class=SDescription></td></tr><tr class="SFunction SIndent2 SMarked"><td class=SEntry><a href="#random_2_bin_num.new" id=link7 onMouseOver="ShowTip(event, 'tt7', 'link7')" onMouseOut="HideTip('tt7')">new</a></td><td class=SDescription>Create a random number object.</td></tr><tr class="SClass"><td class=SEntry><a href="#random_4_bin_num" id=link8 onMouseOver="ShowTip(event, 'tt8', 'link8')" onMouseOut="HideTip('tt8')">random_4_bin_num</a></td><td class=SDescription>Provides a random number using four distribution bins.</td></tr><tr class="SGroup SIndent1"><td class=SEntry><a href="#random_4_bin_num.Properties" >Properties</a></td><td class=SDescription></td></tr><tr class="SProperty SIndent2 SMarked"><td class=SEntry><a href="#random_4_bin_num.db" id=link9 onMouseOver="ShowTip(event, 'tt9', 'link9')" onMouseOut="HideTip('tt9')">db</a></td><td class=SDescription>Random distribution bins. </td></tr><tr class="SProperty SIndent2"><td class=SEntry><a href="#random_4_bin_num.val" id=link10 onMouseOver="ShowTip(event, 'tt10', 'link10')" onMouseOut="HideTip('tt10')">val</a></td><td class=SDescription><span class="rand">rand</span> The randomized value.</td></tr><tr class="SGroup SIndent1"><td class=SEntry><a href="#random_4_bin_num.Functions" >Functions</a></td><td class=SDescription></td></tr><tr class="SFunction SIndent2 SMarked"><td class=SEntry><a href="#random_4_bin_num.new" id=link11 onMouseOver="ShowTip(event, 'tt11', 'link11')" onMouseOut="HideTip('tt11')">new</a></td><td class=SDescription>Create a random number object.</td></tr><tr class="SClass"><td class=SEntry><a href="#random_8_bin_num" id=link12 onMouseOver="ShowTip(event, 'tt12', 'link12')" onMouseOut="HideTip('tt12')">random_8_bin_num</a></td><td class=SDescription>Provides a random number using eight distribution bins.</td></tr><tr class="SGroup SIndent1"><td class=SEntry><a href="#random_8_bin_num.Properties" >Properties</a></td><td class=SDescription></td></tr><tr class="SProperty SIndent2 SMarked"><td class=SEntry><a href="#random_8_bin_num.db" id=link13 onMouseOver="ShowTip(event, 'tt13', 'link13')" onMouseOut="HideTip('tt13')">db</a></td><td class=SDescription>Random distribution bins. </td></tr><tr class="SProperty SIndent2"><td class=SEntry><a href="#random_8_bin_num.val" id=link14 onMouseOver="ShowTip(event, 'tt14', 'link14')" onMouseOut="HideTip('tt14')">val</a></td><td class=SDescription><span class="rand">rand</span> The randomized value.</td></tr><tr class="SGroup SIndent1"><td class=SEntry><a href="#random_8_bin_num.Functions" >Functions</a></td><td class=SDescription></td></tr><tr class="SFunction SIndent2 SMarked"><td class=SEntry><a href="#random_8_bin_num.new" id=link15 onMouseOver="ShowTip(event, 'tt15', 'link15')" onMouseOut="HideTip('tt15')">new</a></td><td class=SDescription>Create a random number object.</td></tr><tr class="SClass"><td class=SEntry><a href="#random_16_bin_num" id=link16 onMouseOver="ShowTip(event, 'tt16', 'link16')" onMouseOut="HideTip('tt16')">random_16_bin_num</a></td><td class=SDescription>Provides a random number using sixteen distribution bins. </td></tr><tr class="SGroup SIndent1"><td class=SEntry><a href="#random_16_bin_num.Properties" >Properties</a></td><td class=SDescription></td></tr><tr class="SProperty SIndent2 SMarked"><td class=SEntry><a href="#random_16_bin_num.db" id=link17 onMouseOver="ShowTip(event, 'tt17', 'link17')" onMouseOut="HideTip('tt17')">db</a></td><td class=SDescription>Random distribution bins. </td></tr><tr class="SProperty SIndent2"><td class=SEntry><a href="#random_16_bin_num.val" id=link18 onMouseOver="ShowTip(event, 'tt18', 'link18')" onMouseOut="HideTip('tt18')">val</a></td><td class=SDescription><span class="rand">rand</span> The randomized value.</td></tr><tr class="SGroup SIndent1"><td class=SEntry><a href="#random_16_bin_num.Functions" >Functions</a></td><td class=SDescription></td></tr><tr class="SFunction SIndent2 SMarked"><td class=SEntry><a href="#random_16_bin_num.new" id=link19 onMouseOver="ShowTip(event, 'tt19', 'link19')" onMouseOut="HideTip('tt19')">new</a></td><td class=SDescription>Create a random number object.</td></tr><tr class="SClass"><td class=SEntry><a href="#random_32_bin_num" id=link20 onMouseOver="ShowTip(event, 'tt20', 'link20')" onMouseOut="HideTip('tt20')">random_32_bin_num</a></td><td class=SDescription>Provides a random number using thirty-two distribution bins. </td></tr><tr class="SGroup SIndent1"><td class=SEntry><a href="#random_32_bin_num.Properties" >Properties</a></td><td class=SDescription></td></tr><tr class="SProperty SIndent2 SMarked"><td class=SEntry><a href="#random_32_bin_num.db" id=link21 onMouseOver="ShowTip(event, 'tt21', 'link21')" onMouseOut="HideTip('tt21')">db</a></td><td class=SDescription>Random distribution bins. </td></tr><tr class="SProperty SIndent2"><td class=SEntry><a href="#random_32_bin_num.val" id=link22 onMouseOver="ShowTip(event, 'tt22', 'link22')" onMouseOut="HideTip('tt22')">val</a></td><td class=SDescription><span class="rand">rand</span> The randomized value.</td></tr><tr class="SGroup SIndent1"><td class=SEntry><a href="#random_32_bin_num.Functions" >Functions</a></td><td class=SDescription></td></tr><tr class="SFunction SIndent2 SMarked"><td class=SEntry><a href="#random_32_bin_num.new" id=link23 onMouseOver="ShowTip(event, 'tt23', 'link23')" onMouseOut="HideTip('tt23')">new</a></td><td class=SDescription>Create a random number object.</td></tr><tr class="SClass"><td class=SEntry><a href="#random_power_of_2_num" id=link24 onMouseOver="ShowTip(event, 'tt24', 'link24')" onMouseOut="HideTip('tt24')">random_power_of_2_num</a></td><td class=SDescription>Provides a random number with power-of-two distributions. </td></tr><tr class="SGroup SIndent1"><td class=SEntry><a href="#random_power_of_2_num.Properties" >Properties</a></td><td class=SDescription></td></tr><tr class="SProperty SIndent2 SMarked"><td class=SEntry><a href="#random_power_of_2_num.min_val" id=link25 onMouseOver="ShowTip(event, 'tt25', 'link25')" onMouseOut="HideTip('tt25')">min_val</a></td><td class=SDescription>The minimum limit of <b>val</b>. </td></tr><tr class="SProperty SIndent2"><td class=SEntry><a href="#random_power_of_2_num.max_val" id=link26 onMouseOver="ShowTip(event, 'tt26', 'link26')" onMouseOut="HideTip('tt26')">max_val</a></td><td class=SDescription>The maximum limit of <b>val</b>. </td></tr><tr class="SGroup SIndent1"><td class=SEntry><a href="#random_power_of_2_num.Functions" >Functions</a></td><td class=SDescription></td></tr><tr class="SFunction SIndent2 SMarked"><td class=SEntry><a href="#random_power_of_2_num.new" id=link27 onMouseOver="ShowTip(event, 'tt27', 'link27')" onMouseOut="HideTip('tt27')">new</a></td><td class=SDescription>Create a random number object.</td></tr><tr class="SClass"><td class=SEntry><a href="#random_power_of_10_num" id=link28 onMouseOver="ShowTip(event, 'tt28', 'link28')" onMouseOut="HideTip('tt28')">random_power_of_10_num</a></td><td class=SDescription>Provides a random number with power-of-ten distributions. </td></tr><tr class="SGroup SIndent1"><td class=SEntry><a href="#random_power_of_10_num.Properties" >Properties</a></td><td class=SDescription></td></tr><tr class="SProperty SIndent2 SMarked"><td class=SEntry><a href="#random_power_of_10_num.min_val" id=link29 onMouseOver="ShowTip(event, 'tt29', 'link29')" onMouseOut="HideTip('tt29')">min_val</a></td><td class=SDescription>The minimum limit of <b>val</b>. </td></tr><tr class="SProperty SIndent2"><td class=SEntry><a href="#random_power_of_10_num.max_val" id=link30 onMouseOver="ShowTip(event, 'tt30', 'link30')" onMouseOut="HideTip('tt30')">max_val</a></td><td class=SDescription>The maximum limit of <b>val</b>. </td></tr><tr class="SGroup SIndent1"><td class=SEntry><a href="#random_power_of_10_num.Functions" >Functions</a></td><td class=SDescription></td></tr><tr class="SFunction SIndent2 SMarked"><td class=SEntry><a href="#random_power_of_10_num.new" id=link31 onMouseOver="ShowTip(event, 'tt31', 'link31')" onMouseOut="HideTip('tt31')">new</a></td><td class=SDescription>Create a random number object.</td></tr></table></div></div><!--END_ND_SUMMARY--></div></div></div>

<div class="CGroup"><div class=CTopic><h3 class=CTitle><a name="Types"></a>Types</h3></div></div>

<div class="CType"><div class=CTopic><h3 class=CTitle><a name="dist_bin"></a>dist_bin</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">typedef struct { int min_val; int max_val; byte unsigned wt /*= 0*/; } dist_bin</td></tr></table></blockquote><p>Defines the structure of a random distribution bin.</p><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>min_val</td><td class=CDLDescription>The minimum value of a bin.</td></tr><tr><td class=CDLEntry>max_val</td><td class=CDLDescription>The maximum value of a bin.</td></tr><tr><td class=CDLEntry>wt</td><td class=CDLDescription>The distribution weight of a bin.</td></tr></table></div></div></div>

<div class="CClass"><div class=CTopic><h2 class=CTitle><a name="random_util"></a>random_util</h2><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">class random_util</td></tr></table></blockquote><p>Provides a utility function to generate random numbers.</p><!--START_ND_SUMMARY--><div class=Summary><div class=STitle>Summary</div><div class=SBorder><table border=0 cellspacing=0 cellpadding=0 class=STable><tr class="SGroup"><td class=SEntry><a href="#random_util.Functions" >Functions</a></td><td class=SDescription></td></tr><tr class="SFunction SIndent1 SMarked"><td class=SEntry><a href="#random_util.random_bool" id=link32 onMouseOver="ShowTip(event, 'tt3', 'link32')" onMouseOut="HideTip('tt3')">random_bool</a></td><td class=SDescription><span class="static">static</span> Returns a randomized Boolean value based on the specified percentage.</td></tr></table></div></div><!--END_ND_SUMMARY--></div></div></div>

<div class="CGroup"><div class=CTopic><h3 class=CTitle><a name="random_util.Functions"></a>Functions</h3></div></div>

<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="random_util.random_bool"></a>random_bool</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>static function bit random_bool(</td><td class="PTypePrefix  prettyprint " nowrap>int&nbsp;</td><td class="PType  prettyprint " nowrap>unsigned&nbsp;</td><td class="PParameter  prettyprint " nowrap>true_pct</td><td class="PDefaultValuePrefix  prettyprint ">&nbsp;=&nbsp;</td><td class="PDefaultValue  prettyprint " width=100%> 50</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><p><span class="static">static</span> Returns a randomized Boolean value based on the specified percentage.</p><h4 class=CHeading>Argument</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>true_pct</td><td class=CDLDescription><span class="optional">optional</span> The probability of the returned value to be randomized to 1 (true).&nbsp; The unit is a percent.&nbsp; The default is 50 (50% true).</td></tr></table><h4 class=CHeading>Returns</h4><p>The randomized Boolean value (1 or 0).</p><h4 class=CHeading>Example</h4><blockquote><pre class="prettyprint">bit rb = random_util::random_bool( .true_pct( 70 ) ); // 70% true</pre></blockquote></div></div></div>

<div class="CClass"><div class=CTopic><h2 class=CTitle><a name="random_2_bin_num"></a>random_2_bin_num</h2><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">class random_2_bin_num</td></tr></table></blockquote><p>Provides a random number using two distribution bins.</p><h4 class=CHeading>Example</h4><p>The value of variable <b>n.val</b> is randomzed to between 0 and 9, or 10 and 19 with a weighted ratio of 1-2.</p><blockquote><pre class="prettyprint">random_2_bin_num n = new();

//          min max wt
n.db[0] = '{  0,  9, 1 }; // bin 0
n.db[1] = '{ 10, 19, 2 }; // bin 1

assert( n.randomize() );
$display( n.val );</pre></blockquote><!--START_ND_SUMMARY--><div class=Summary><div class=STitle>Summary</div><div class=SBorder><table border=0 cellspacing=0 cellpadding=0 class=STable><tr class="SGroup"><td class=SEntry><a href="#random_2_bin_num.Properties" >Properties</a></td><td class=SDescription></td></tr><tr class="SProperty SIndent1 SMarked"><td class=SEntry><a href="#random_2_bin_num.db" id=link33 onMouseOver="ShowTip(event, 'tt5', 'link33')" onMouseOut="HideTip('tt5')">db</a></td><td class=SDescription>Random distribution bins. </td></tr><tr class="SProperty SIndent1"><td class=SEntry><a href="#random_2_bin_num.val" id=link34 onMouseOver="ShowTip(event, 'tt6', 'link34')" onMouseOut="HideTip('tt6')">val</a></td><td class=SDescription><span class="rand">rand</span> The randomized value.</td></tr><tr class="SGroup"><td class=SEntry><a href="#random_2_bin_num.Functions" >Functions</a></td><td class=SDescription></td></tr><tr class="SFunction SIndent1 SMarked"><td class=SEntry><a href="#random_2_bin_num.new" id=link35 onMouseOver="ShowTip(event, 'tt7', 'link35')" onMouseOut="HideTip('tt7')">new</a></td><td class=SDescription>Create a random number object.</td></tr></table></div></div><!--END_ND_SUMMARY--></div></div></div>

<div class="CGroup"><div class=CTopic><h3 class=CTitle><a name="random_2_bin_num.Properties"></a>Properties</h3></div></div>

<div class="CProperty"><div class=CTopic><h3 class=CTitle><a name="random_2_bin_num.db"></a>db</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">dist_bin db[2]</td></tr></table></blockquote><p>Random distribution bins.&nbsp; The distribution weight of unused bins are set to be 0.</p></div></div></div>

<div class="CProperty"><div class=CTopic><h3 class=CTitle><a name="random_2_bin_num.val"></a>val</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">rand int val</td></tr></table></blockquote><p><span class="rand">rand</span> The randomized value.</p></div></div></div>

<div class="CGroup"><div class=CTopic><h3 class=CTitle><a name="random_2_bin_num.Functions"></a>Functions</h3></div></div>

<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="random_2_bin_num.new"></a>new</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>function new(</td><td class="PType  prettyprint " nowrap>int&nbsp;</td><td class="PParameter  prettyprint " nowrap>default_val</td><td class="PDefaultValuePrefix  prettyprint ">&nbsp;=&nbsp;</td><td class="PDefaultValue  prettyprint " width=100%> 0</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><p>Create a random number object.</p><h4 class=CHeading>Argument</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>default_val</td><td class=CDLDescription><span class="optional">optional</span> The value of <b>val</b> before randomization.&nbsp; The default is 0.</td></tr></table></div></div></div>

<div class="CClass"><div class=CTopic><h2 class=CTitle><a name="random_4_bin_num"></a>random_4_bin_num</h2><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">class random_4_bin_num</td></tr></table></blockquote><p>Provides a random number using four distribution bins.</p><h4 class=CHeading>Example</h4><p>The value of variable <b>n.val</b> is randomzed to between 0 and 9, 10 and 19, 20 and 29, or 30 and 39 with a weighted ratio of 1-2-3-4.</p><blockquote><pre class="prettyprint">random_4_bin_num n = new();

//          min max wt
n.db[0] = '{  0,  9, 1 }; // bin 0
n.db[1] = '{ 10, 19, 2 }; // bin 1
n.db[2] = '{ 20, 29, 3 }; // bin 2
n.db[3] = '{ 30, 39, 4 }; // bin 3

assert( n.randomize() );
$display( n.val );</pre></blockquote><!--START_ND_SUMMARY--><div class=Summary><div class=STitle>Summary</div><div class=SBorder><table border=0 cellspacing=0 cellpadding=0 class=STable><tr class="SGroup"><td class=SEntry><a href="#random_4_bin_num.Properties" >Properties</a></td><td class=SDescription></td></tr><tr class="SProperty SIndent1 SMarked"><td class=SEntry><a href="#random_4_bin_num.db" id=link36 onMouseOver="ShowTip(event, 'tt9', 'link36')" onMouseOut="HideTip('tt9')">db</a></td><td class=SDescription>Random distribution bins. </td></tr><tr class="SProperty SIndent1"><td class=SEntry><a href="#random_4_bin_num.val" id=link37 onMouseOver="ShowTip(event, 'tt10', 'link37')" onMouseOut="HideTip('tt10')">val</a></td><td class=SDescription><span class="rand">rand</span> The randomized value.</td></tr><tr class="SGroup"><td class=SEntry><a href="#random_4_bin_num.Functions" >Functions</a></td><td class=SDescription></td></tr><tr class="SFunction SIndent1 SMarked"><td class=SEntry><a href="#random_4_bin_num.new" id=link38 onMouseOver="ShowTip(event, 'tt11', 'link38')" onMouseOut="HideTip('tt11')">new</a></td><td class=SDescription>Create a random number object.</td></tr></table></div></div><!--END_ND_SUMMARY--></div></div></div>

<div class="CGroup"><div class=CTopic><h3 class=CTitle><a name="random_4_bin_num.Properties"></a>Properties</h3></div></div>

<div class="CProperty"><div class=CTopic><h3 class=CTitle><a name="random_4_bin_num.db"></a>db</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">dist_bin db[4]</td></tr></table></blockquote><p>Random distribution bins.&nbsp; The distribution weight of unused bins are set to be 0.</p></div></div></div>

<div class="CProperty"><div class=CTopic><h3 class=CTitle><a name="random_4_bin_num.val"></a>val</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">rand int val</td></tr></table></blockquote><p><span class="rand">rand</span> The randomized value.</p></div></div></div>

<div class="CGroup"><div class=CTopic><h3 class=CTitle><a name="random_4_bin_num.Functions"></a>Functions</h3></div></div>

<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="random_4_bin_num.new"></a>new</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>function new(</td><td class="PType  prettyprint " nowrap>int&nbsp;</td><td class="PParameter  prettyprint " nowrap>default_val</td><td class="PDefaultValuePrefix  prettyprint ">&nbsp;=&nbsp;</td><td class="PDefaultValue  prettyprint " width=100%> 0</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><p>Create a random number object.</p><h4 class=CHeading>Argument</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>default_val</td><td class=CDLDescription><span class="optional">optional</span> The value of <b>val</b> before randomization.&nbsp; The default is 0.</td></tr></table></div></div></div>

<div class="CClass"><div class=CTopic><h2 class=CTitle><a name="random_8_bin_num"></a>random_8_bin_num</h2><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">class random_8_bin_num</td></tr></table></blockquote><p>Provides a random number using eight distribution bins.</p><h4 class=CHeading>Example</h4><p>The value of variable <b>n.val</b> is randomzed to between 0 and 9, 10 and 19, 20 and 29, 30 and 39, 40 and 49, 50 and 59, 60 and 69, or 70 and 79 with a weighted ratio of 1-2-3-4-5-6-7-8.</p><blockquote><pre class="prettyprint">random_8_bin_num n = new();

//          min max wt
n.db[0] = '{  0,  9, 1 }; // bin 0
n.db[1] = '{ 10, 19, 2 }; // bin 1
n.db[2] = '{ 20, 29, 3 }; // bin 2
n.db[3] = '{ 30, 39, 4 }; // bin 3
n.db[4] = '{ 40, 49, 5 }; // bin 4
n.db[5] = '{ 50, 59, 6 }; // bin 5
n.db[6] = '{ 60, 69, 7 }; // bin 6
n.db[7] = '{ 70, 79, 8 }; // bin 7

assert( n.randomize() );
$display( n.val );</pre></blockquote><!--START_ND_SUMMARY--><div class=Summary><div class=STitle>Summary</div><div class=SBorder><table border=0 cellspacing=0 cellpadding=0 class=STable><tr class="SGroup"><td class=SEntry><a href="#random_8_bin_num.Properties" >Properties</a></td><td class=SDescription></td></tr><tr class="SProperty SIndent1 SMarked"><td class=SEntry><a href="#random_8_bin_num.db" id=link39 onMouseOver="ShowTip(event, 'tt13', 'link39')" onMouseOut="HideTip('tt13')">db</a></td><td class=SDescription>Random distribution bins. </td></tr><tr class="SProperty SIndent1"><td class=SEntry><a href="#random_8_bin_num.val" id=link40 onMouseOver="ShowTip(event, 'tt14', 'link40')" onMouseOut="HideTip('tt14')">val</a></td><td class=SDescription><span class="rand">rand</span> The randomized value.</td></tr><tr class="SGroup"><td class=SEntry><a href="#random_8_bin_num.Functions" >Functions</a></td><td class=SDescription></td></tr><tr class="SFunction SIndent1 SMarked"><td class=SEntry><a href="#random_8_bin_num.new" id=link41 onMouseOver="ShowTip(event, 'tt15', 'link41')" onMouseOut="HideTip('tt15')">new</a></td><td class=SDescription>Create a random number object.</td></tr></table></div></div><!--END_ND_SUMMARY--></div></div></div>

<div class="CGroup"><div class=CTopic><h3 class=CTitle><a name="random_8_bin_num.Properties"></a>Properties</h3></div></div>

<div class="CProperty"><div class=CTopic><h3 class=CTitle><a name="random_8_bin_num.db"></a>db</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">dist_bin db[8]</td></tr></table></blockquote><p>Random distribution bins.&nbsp; The distribution weight of unused bins are set to be 0.</p></div></div></div>

<div class="CProperty"><div class=CTopic><h3 class=CTitle><a name="random_8_bin_num.val"></a>val</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">rand int val</td></tr></table></blockquote><p><span class="rand">rand</span> The randomized value.</p></div></div></div>

<div class="CGroup"><div class=CTopic><h3 class=CTitle><a name="random_8_bin_num.Functions"></a>Functions</h3></div></div>

<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="random_8_bin_num.new"></a>new</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>function new(</td><td class="PType  prettyprint " nowrap>int&nbsp;</td><td class="PParameter  prettyprint " nowrap>default_val</td><td class="PDefaultValuePrefix  prettyprint ">&nbsp;=&nbsp;</td><td class="PDefaultValue  prettyprint " width=100%> 0</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><p>Create a random number object.</p><h4 class=CHeading>Argument</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>default_val</td><td class=CDLDescription><span class="optional">optional</span> The value of <b>val</b> before randomization.&nbsp; The default is 0.</td></tr></table></div></div></div>

<div class="CClass"><div class=CTopic><h2 class=CTitle><a name="random_16_bin_num"></a>random_16_bin_num</h2><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">class random_16_bin_num</td></tr></table></blockquote><p>Provides a random number using sixteen distribution bins.&nbsp; See <a href="#random_8_bin_num" class=LClass id=link45 onMouseOver="ShowTip(event, 'tt12', 'link45')" onMouseOut="HideTip('tt12')">random_8_bin_num</a> for how to use this class.</p><!--START_ND_SUMMARY--><div class=Summary><div class=STitle>Summary</div><div class=SBorder><table border=0 cellspacing=0 cellpadding=0 class=STable><tr class="SGroup"><td class=SEntry><a href="#random_16_bin_num.Properties" >Properties</a></td><td class=SDescription></td></tr><tr class="SProperty SIndent1 SMarked"><td class=SEntry><a href="#random_16_bin_num.db" id=link42 onMouseOver="ShowTip(event, 'tt17', 'link42')" onMouseOut="HideTip('tt17')">db</a></td><td class=SDescription>Random distribution bins. </td></tr><tr class="SProperty SIndent1"><td class=SEntry><a href="#random_16_bin_num.val" id=link43 onMouseOver="ShowTip(event, 'tt18', 'link43')" onMouseOut="HideTip('tt18')">val</a></td><td class=SDescription><span class="rand">rand</span> The randomized value.</td></tr><tr class="SGroup"><td class=SEntry><a href="#random_16_bin_num.Functions" >Functions</a></td><td class=SDescription></td></tr><tr class="SFunction SIndent1 SMarked"><td class=SEntry><a href="#random_16_bin_num.new" id=link44 onMouseOver="ShowTip(event, 'tt19', 'link44')" onMouseOut="HideTip('tt19')">new</a></td><td class=SDescription>Create a random number object.</td></tr></table></div></div><!--END_ND_SUMMARY--></div></div></div>

<div class="CGroup"><div class=CTopic><h3 class=CTitle><a name="random_16_bin_num.Properties"></a>Properties</h3></div></div>

<div class="CProperty"><div class=CTopic><h3 class=CTitle><a name="random_16_bin_num.db"></a>db</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">dist_bin db[16]</td></tr></table></blockquote><p>Random distribution bins.&nbsp; The distribution weight of unused bins are set to be 0.</p></div></div></div>

<div class="CProperty"><div class=CTopic><h3 class=CTitle><a name="random_16_bin_num.val"></a>val</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">rand int val</td></tr></table></blockquote><p><span class="rand">rand</span> The randomized value.</p></div></div></div>

<div class="CGroup"><div class=CTopic><h3 class=CTitle><a name="random_16_bin_num.Functions"></a>Functions</h3></div></div>

<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="random_16_bin_num.new"></a>new</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>function new(</td><td class="PType  prettyprint " nowrap>int&nbsp;</td><td class="PParameter  prettyprint " nowrap>default_val</td><td class="PDefaultValuePrefix  prettyprint ">&nbsp;=&nbsp;</td><td class="PDefaultValue  prettyprint " width=100%> 0</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><p>Create a random number object.</p><h4 class=CHeading>Argument</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>default_val</td><td class=CDLDescription><span class="optional">optional</span> The value of <b>val</b> before randomization.&nbsp; The default is 0.</td></tr></table></div></div></div>

<div class="CClass"><div class=CTopic><h2 class=CTitle><a name="random_32_bin_num"></a>random_32_bin_num</h2><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">class random_32_bin_num</td></tr></table></blockquote><p>Provides a random number using thirty-two distribution bins.&nbsp; See <a href="#random_8_bin_num" class=LClass id=link49 onMouseOver="ShowTip(event, 'tt12', 'link49')" onMouseOut="HideTip('tt12')">random_8_bin_num</a> for how to use this class.</p><!--START_ND_SUMMARY--><div class=Summary><div class=STitle>Summary</div><div class=SBorder><table border=0 cellspacing=0 cellpadding=0 class=STable><tr class="SGroup"><td class=SEntry><a href="#random_32_bin_num.Properties" >Properties</a></td><td class=SDescription></td></tr><tr class="SProperty SIndent1 SMarked"><td class=SEntry><a href="#random_32_bin_num.db" id=link46 onMouseOver="ShowTip(event, 'tt21', 'link46')" onMouseOut="HideTip('tt21')">db</a></td><td class=SDescription>Random distribution bins. </td></tr><tr class="SProperty SIndent1"><td class=SEntry><a href="#random_32_bin_num.val" id=link47 onMouseOver="ShowTip(event, 'tt22', 'link47')" onMouseOut="HideTip('tt22')">val</a></td><td class=SDescription><span class="rand">rand</span> The randomized value.</td></tr><tr class="SGroup"><td class=SEntry><a href="#random_32_bin_num.Functions" >Functions</a></td><td class=SDescription></td></tr><tr class="SFunction SIndent1 SMarked"><td class=SEntry><a href="#random_32_bin_num.new" id=link48 onMouseOver="ShowTip(event, 'tt23', 'link48')" onMouseOut="HideTip('tt23')">new</a></td><td class=SDescription>Create a random number object.</td></tr></table></div></div><!--END_ND_SUMMARY--></div></div></div>

<div class="CGroup"><div class=CTopic><h3 class=CTitle><a name="random_32_bin_num.Properties"></a>Properties</h3></div></div>

<div class="CProperty"><div class=CTopic><h3 class=CTitle><a name="random_32_bin_num.db"></a>db</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">dist_bin db[32]</td></tr></table></blockquote><p>Random distribution bins.&nbsp; The distribution weight of unused bins are set to be 0.</p></div></div></div>

<div class="CProperty"><div class=CTopic><h3 class=CTitle><a name="random_32_bin_num.val"></a>val</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">rand int val</td></tr></table></blockquote><p><span class="rand">rand</span> The randomized value.</p></div></div></div>

<div class="CGroup"><div class=CTopic><h3 class=CTitle><a name="random_32_bin_num.Functions"></a>Functions</h3></div></div>

<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="random_32_bin_num.new"></a>new</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>function new(</td><td class="PType  prettyprint " nowrap>int&nbsp;</td><td class="PParameter  prettyprint " nowrap>default_val</td><td class="PDefaultValuePrefix  prettyprint ">&nbsp;=&nbsp;</td><td class="PDefaultValue  prettyprint " width=100%> 0</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><p>Create a random number object.</p><h4 class=CHeading>Argument</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>default_val</td><td class=CDLDescription><span class="optional">optional</span> The value of <b>val</b> before randomization.&nbsp; The default is 0.</td></tr></table></div></div></div>

<div class="CClass"><div class=CTopic><h2 class=CTitle><a name="random_power_of_2_num"></a>random_power_of_2_num</h2><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">class random_power_of_2_num extends random_32_bin_num</td></tr></table></blockquote><p>Provides a random number with power-of-two distributions.&nbsp; This class uses the following pre-populated distribution bins.</p><blockquote><pre>//           min    max  wt       bin
db = '{ '{     0,     0, 1 },   //  0
        '{     1,     1, 1 },   //  1
        '{     2,     2, 1 },   //  2
        '{     3,     3, 1 },   //  3
        '{     4,     4, 1 },   //  4
        '{     5,     7, 1 },   //  5
        '{     8,     8, 1 },   //  6
        '{     9,    15, 1 },   //  7
        '{    16,    16, 1 },   //  8
        '{    17,    31, 1 },   //  9
        '{    32,    32, 1 },   // 10
        '{    33,    63, 1 },   // 11
        '{    64,    64, 1 },   // 12
        '{    65,   127, 1 },   // 13
        '{   128,   128, 1 },   // 14
        '{   129,   255, 1 },   // 15
        '{   256,   256, 1 },   // 16
        '{   257,   511, 1 },   // 17
        '{   512,   512, 1 },   // 18
        '{   513,  1023, 1 },   // 19
        '{  1024,  1024, 1 },   // 20
        '{  1025,  2047, 1 },   // 21
        '{  2048,  2048, 1 },   // 22
        '{  2049,  4095, 1 },   // 23
        '{  4096,  4096, 1 },   // 24
        '{  4097,  8191, 1 },   // 25
        '{  8192,  8192, 1 },   // 26
        '{  8193, 16383, 1 },   // 27
        '{ 16384, 16384, 1 },   // 28
        '{ 16385, 32767, 1 },   // 29
        '{ 32768, 32768, 1 },   // 30
        '{ 32769, 65535, 1 } }; // 31</pre></blockquote><h4 class=CHeading>Example</h4><blockquote><pre class="prettyprint">random_power_of_2_num n = new();
assert( n.randomize() );
$display( n.val );</pre></blockquote><!--START_ND_SUMMARY--><div class=Summary><div class=STitle>Summary</div><div class=SBorder><table border=0 cellspacing=0 cellpadding=0 class=STable><tr class="SGroup"><td class=SEntry><a href="#random_power_of_2_num.Properties" >Properties</a></td><td class=SDescription></td></tr><tr class="SProperty SIndent1 SMarked"><td class=SEntry><a href="#random_power_of_2_num.min_val" id=link50 onMouseOver="ShowTip(event, 'tt25', 'link50')" onMouseOut="HideTip('tt25')">min_val</a></td><td class=SDescription>The minimum limit of <b>val</b>. </td></tr><tr class="SProperty SIndent1"><td class=SEntry><a href="#random_power_of_2_num.max_val" id=link51 onMouseOver="ShowTip(event, 'tt26', 'link51')" onMouseOut="HideTip('tt26')">max_val</a></td><td class=SDescription>The maximum limit of <b>val</b>. </td></tr><tr class="SGroup"><td class=SEntry><a href="#random_power_of_2_num.Functions" >Functions</a></td><td class=SDescription></td></tr><tr class="SFunction SIndent1 SMarked"><td class=SEntry><a href="#random_power_of_2_num.new" id=link52 onMouseOver="ShowTip(event, 'tt27', 'link52')" onMouseOut="HideTip('tt27')">new</a></td><td class=SDescription>Create a random number object.</td></tr></table></div></div><!--END_ND_SUMMARY--></div></div></div>

<div class="CGroup"><div class=CTopic><h3 class=CTitle><a name="random_power_of_2_num.Properties"></a>Properties</h3></div></div>

<div class="CProperty"><div class=CTopic><h3 class=CTitle><a name="random_power_of_2_num.min_val"></a>min_val</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">int min_val</td></tr></table></blockquote><p>The minimum limit of <b>val</b>.&nbsp; The <b>val</b> is randomized to be at least this value.</p></div></div></div>

<div class="CProperty"><div class=CTopic><h3 class=CTitle><a name="random_power_of_2_num.max_val"></a>max_val</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">int max_val</td></tr></table></blockquote><p>The maximum limit of <b>val</b>.&nbsp; The <b>val</b> is randomized to be at most this value.</p></div></div></div>

<div class="CGroup"><div class=CTopic><h3 class=CTitle><a name="random_power_of_2_num.Functions"></a>Functions</h3></div></div>

<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="random_power_of_2_num.new"></a>new</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>function new(</td><td class="PType  prettyprint " nowrap>int&nbsp;</td><td class="PParameter  prettyprint " nowrap>default_val</td><td class="PDefaultValuePrefix  prettyprint ">&nbsp;=&nbsp;</td><td class="PDefaultValue  prettyprint " width=100%> 0,</td></tr><tr><td></td><td class="PType  prettyprint " nowrap>int&nbsp;</td><td class="PParameter  prettyprint " nowrap>min_val</td><td class="PDefaultValuePrefix  prettyprint ">&nbsp;=&nbsp;</td><td class="PDefaultValue  prettyprint " width=100%> 0,</td></tr><tr><td></td><td class="PType  prettyprint " nowrap>int&nbsp;</td><td class="PParameter  prettyprint " nowrap>max_val</td><td class="PDefaultValuePrefix  prettyprint ">&nbsp;=&nbsp;</td><td class="PDefaultValue  prettyprint " width=100%> 65535</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><p>Create a random number object.</p><h4 class=CHeading>Argument</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>default_val</td><td class=CDLDescription><span class="optional">optional</span> The value of <b>val</b> before randomization.&nbsp; The default is 0.</td></tr><tr><td class=CDLEntry>min_val</td><td class=CDLDescription><span class="optional">optional</span> The minimum limit of <b>val</b>.&nbsp; The <b>val</b> is randomized to be at least this value.&nbsp; The default is 0.</td></tr><tr><td class=CDLEntry>max_val</td><td class=CDLDescription><span class="optional">optional</span> The maximum limit of <b>val</b>.&nbsp; The <b>val</b> is randomized to be at most this value.&nbsp; The default is 65,535.</td></tr></table></div></div></div>

<div class="CClass"><div class=CTopic><h2 class=CTitle><a name="random_power_of_10_num"></a>random_power_of_10_num</h2><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">class random_power_of_10_num extends random_16_bin_num</td></tr></table></blockquote><p>Provides a random number with power-of-ten distributions.&nbsp; This class uses the following pre-populated distribution bins.</p><blockquote><pre>//                min         max  wt       bin
db = '{ '{          0,          0, 1 },   //  0
        '{          1,          1, 1 },   //  1
        '{          2,          9, 1 },   //  2
        '{         10,         10, 1 },   //  3
        '{         11,         99, 1 },   //  4
        '{        100,        100, 1 },   //  5
        '{        101,        999, 1 },   //  6
        '{      1_000,      1_000, 1 },   //  7
        '{      1_001,      9_999, 1 },   //  8
        '{     10_000,     10_000, 1 },   //  9
        '{     10_001,     99_999, 1 },   // 10
        '{    100_000,    100_000, 1 },   // 11
        '{    100_001,    999_999, 1 },   // 12
        '{  1_000_000,  1_000_000, 1 },   // 13
        '{  1_000_001,  9_999_999, 1 },   // 14
        '{ 10_000_000, 10_000_000, 1 } }; // 15</pre></blockquote><h4 class=CHeading>Example</h4><blockquote><pre class="prettyprint">random_power_of_10_num n = new();
assert( n.randomize() );
$display( n.val );</pre></blockquote><!--START_ND_SUMMARY--><div class=Summary><div class=STitle>Summary</div><div class=SBorder><table border=0 cellspacing=0 cellpadding=0 class=STable><tr class="SGroup"><td class=SEntry><a href="#random_power_of_10_num.Properties" >Properties</a></td><td class=SDescription></td></tr><tr class="SProperty SIndent1 SMarked"><td class=SEntry><a href="#random_power_of_10_num.min_val" id=link53 onMouseOver="ShowTip(event, 'tt29', 'link53')" onMouseOut="HideTip('tt29')">min_val</a></td><td class=SDescription>The minimum limit of <b>val</b>. </td></tr><tr class="SProperty SIndent1"><td class=SEntry><a href="#random_power_of_10_num.max_val" id=link54 onMouseOver="ShowTip(event, 'tt30', 'link54')" onMouseOut="HideTip('tt30')">max_val</a></td><td class=SDescription>The maximum limit of <b>val</b>. </td></tr><tr class="SGroup"><td class=SEntry><a href="#random_power_of_10_num.Functions" >Functions</a></td><td class=SDescription></td></tr><tr class="SFunction SIndent1 SMarked"><td class=SEntry><a href="#random_power_of_10_num.new" id=link55 onMouseOver="ShowTip(event, 'tt31', 'link55')" onMouseOut="HideTip('tt31')">new</a></td><td class=SDescription>Create a random number object.</td></tr></table></div></div><!--END_ND_SUMMARY--></div></div></div>

<div class="CGroup"><div class=CTopic><h3 class=CTitle><a name="random_power_of_10_num.Properties"></a>Properties</h3></div></div>

<div class="CProperty"><div class=CTopic><h3 class=CTitle><a name="random_power_of_10_num.min_val"></a>min_val</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">int min_val</td></tr></table></blockquote><p>The minimum limit of <b>val</b>.&nbsp; The <b>val</b> is randomized to be at least this value.</p></div></div></div>

<div class="CProperty"><div class=CTopic><h3 class=CTitle><a name="random_power_of_10_num.max_val"></a>max_val</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">int max_val</td></tr></table></blockquote><p>The maximum limit of <b>val</b>.&nbsp; The <b>val</b> is randomized to be at most this value.</p></div></div></div>

<div class="CGroup"><div class=CTopic><h3 class=CTitle><a name="random_power_of_10_num.Functions"></a>Functions</h3></div></div>

<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="random_power_of_10_num.new"></a>new</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>function new(</td><td class="PType  prettyprint " nowrap>int&nbsp;</td><td class="PParameter  prettyprint " nowrap>default_val</td><td class="PDefaultValuePrefix  prettyprint ">&nbsp;=&nbsp;</td><td class="PDefaultValue  prettyprint " width=100%> 0,</td></tr><tr><td></td><td class="PType  prettyprint " nowrap>int&nbsp;</td><td class="PParameter  prettyprint " nowrap>min_val</td><td class="PDefaultValuePrefix  prettyprint ">&nbsp;=&nbsp;</td><td class="PDefaultValue  prettyprint " width=100%> 0,</td></tr><tr><td></td><td class="PType  prettyprint " nowrap>int&nbsp;</td><td class="PParameter  prettyprint " nowrap>max_val</td><td class="PDefaultValuePrefix  prettyprint ">&nbsp;=&nbsp;</td><td class="PDefaultValue  prettyprint " width=100%> 10_000_000</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><p>Create a random number object.</p><h4 class=CHeading>Argument</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>default_val</td><td class=CDLDescription><span class="optional">optional</span> The value of <b>val</b> before randomization.&nbsp; The default is 0.</td></tr><tr><td class=CDLEntry>min_val</td><td class=CDLDescription><span class="optional">optional</span> The minimum limit of <b>val</b>.&nbsp; The <b>val</b> is randomized to be at least this value.&nbsp; The default is 0.</td></tr><tr><td class=CDLEntry>max_val</td><td class=CDLDescription><span class="optional">optional</span> The maximum limit of <b>val</b>.&nbsp; The <b>val</b> is randomized to be at most this value.&nbsp; The default is 10,000,000.</td></tr></table></div></div></div>

</div><!--Content-->



<!--START_ND_TOOLTIPS-->
<div class=CToolTip id="tt1"><div class=CType><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">typedef struct { int min_val; int max_val; byte unsigned wt /*= 0*/; } dist_bin</td></tr></table></blockquote>Defines the structure of a random distribution bin.</div></div><div class=CToolTip id="tt2"><div class=CClass><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">class random_util</td></tr></table></blockquote>Provides a utility function to generate random numbers.</div></div><div class=CToolTip id="tt3"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>static function bit random_bool(</td><td class="PTypePrefix  prettyprint " nowrap>int&nbsp;</td><td class="PType  prettyprint " nowrap>unsigned&nbsp;</td><td class="PParameter  prettyprint " nowrap>true_pct</td><td class="PDefaultValuePrefix  prettyprint ">&nbsp;=&nbsp;</td><td class="PDefaultValue  prettyprint " width=100%> 50</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><span class="static">static</span> Returns a randomized Boolean value based on the specified percentage.</div></div><div class=CToolTip id="tt4"><div class=CClass><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">class random_2_bin_num</td></tr></table></blockquote>Provides a random number using two distribution bins.</div></div><div class=CToolTip id="tt5"><div class=CProperty><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">dist_bin db[2]</td></tr></table></blockquote>Random distribution bins. </div></div><div class=CToolTip id="tt6"><div class=CProperty><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">rand int val</td></tr></table></blockquote><span class="rand">rand</span> The randomized value.</div></div><div class=CToolTip id="tt7"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>function new(</td><td class="PType  prettyprint " nowrap>int&nbsp;</td><td class="PParameter  prettyprint " nowrap>default_val</td><td class="PDefaultValuePrefix  prettyprint ">&nbsp;=&nbsp;</td><td class="PDefaultValue  prettyprint " width=100%> 0</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote>Create a random number object.</div></div><div class=CToolTip id="tt8"><div class=CClass><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">class random_4_bin_num</td></tr></table></blockquote>Provides a random number using four distribution bins.</div></div><div class=CToolTip id="tt9"><div class=CProperty><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">dist_bin db[4]</td></tr></table></blockquote>Random distribution bins. </div></div><div class=CToolTip id="tt10"><div class=CProperty><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">rand int val</td></tr></table></blockquote><span class="rand">rand</span> The randomized value.</div></div><div class=CToolTip id="tt11"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>function new(</td><td class="PType  prettyprint " nowrap>int&nbsp;</td><td class="PParameter  prettyprint " nowrap>default_val</td><td class="PDefaultValuePrefix  prettyprint ">&nbsp;=&nbsp;</td><td class="PDefaultValue  prettyprint " width=100%> 0</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote>Create a random number object.</div></div><div class=CToolTip id="tt12"><div class=CClass><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">class random_8_bin_num</td></tr></table></blockquote>Provides a random number using eight distribution bins.</div></div><div class=CToolTip id="tt13"><div class=CProperty><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">dist_bin db[8]</td></tr></table></blockquote>Random distribution bins. </div></div><div class=CToolTip id="tt14"><div class=CProperty><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">rand int val</td></tr></table></blockquote><span class="rand">rand</span> The randomized value.</div></div><div class=CToolTip id="tt15"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>function new(</td><td class="PType  prettyprint " nowrap>int&nbsp;</td><td class="PParameter  prettyprint " nowrap>default_val</td><td class="PDefaultValuePrefix  prettyprint ">&nbsp;=&nbsp;</td><td class="PDefaultValue  prettyprint " width=100%> 0</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote>Create a random number object.</div></div><div class=CToolTip id="tt16"><div class=CClass><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">class random_16_bin_num</td></tr></table></blockquote>Provides a random number using sixteen distribution bins. </div></div><div class=CToolTip id="tt17"><div class=CProperty><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">dist_bin db[16]</td></tr></table></blockquote>Random distribution bins. </div></div><div class=CToolTip id="tt18"><div class=CProperty><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">rand int val</td></tr></table></blockquote><span class="rand">rand</span> The randomized value.</div></div><div class=CToolTip id="tt19"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>function new(</td><td class="PType  prettyprint " nowrap>int&nbsp;</td><td class="PParameter  prettyprint " nowrap>default_val</td><td class="PDefaultValuePrefix  prettyprint ">&nbsp;=&nbsp;</td><td class="PDefaultValue  prettyprint " width=100%> 0</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote>Create a random number object.</div></div><div class=CToolTip id="tt20"><div class=CClass><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">class random_32_bin_num</td></tr></table></blockquote>Provides a random number using thirty-two distribution bins. </div></div><div class=CToolTip id="tt21"><div class=CProperty><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">dist_bin db[32]</td></tr></table></blockquote>Random distribution bins. </div></div><div class=CToolTip id="tt22"><div class=CProperty><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">rand int val</td></tr></table></blockquote><span class="rand">rand</span> The randomized value.</div></div><div class=CToolTip id="tt23"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>function new(</td><td class="PType  prettyprint " nowrap>int&nbsp;</td><td class="PParameter  prettyprint " nowrap>default_val</td><td class="PDefaultValuePrefix  prettyprint ">&nbsp;=&nbsp;</td><td class="PDefaultValue  prettyprint " width=100%> 0</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote>Create a random number object.</div></div><div class=CToolTip id="tt24"><div class=CClass><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">class random_power_of_2_num extends random_32_bin_num</td></tr></table></blockquote>Provides a random number with power-of-two distributions. </div></div><div class=CToolTip id="tt25"><div class=CProperty><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">int min_val</td></tr></table></blockquote>The minimum limit of <b>val</b>. </div></div><div class=CToolTip id="tt26"><div class=CProperty><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">int max_val</td></tr></table></blockquote>The maximum limit of <b>val</b>. </div></div><div class=CToolTip id="tt27"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>function new(</td><td class="PType  prettyprint " nowrap>int&nbsp;</td><td class="PParameter  prettyprint " nowrap>default_val</td><td class="PDefaultValuePrefix  prettyprint ">&nbsp;=&nbsp;</td><td class="PDefaultValue  prettyprint " width=100%> 0,</td></tr><tr><td></td><td class="PType  prettyprint " nowrap>int&nbsp;</td><td class="PParameter  prettyprint " nowrap>min_val</td><td class="PDefaultValuePrefix  prettyprint ">&nbsp;=&nbsp;</td><td class="PDefaultValue  prettyprint " width=100%> 0,</td></tr><tr><td></td><td class="PType  prettyprint " nowrap>int&nbsp;</td><td class="PParameter  prettyprint " nowrap>max_val</td><td class="PDefaultValuePrefix  prettyprint ">&nbsp;=&nbsp;</td><td class="PDefaultValue  prettyprint " width=100%> 65535</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote>Create a random number object.</div></div><div class=CToolTip id="tt28"><div class=CClass><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">class random_power_of_10_num extends random_16_bin_num</td></tr></table></blockquote>Provides a random number with power-of-ten distributions. </div></div><div class=CToolTip id="tt29"><div class=CProperty><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">int min_val</td></tr></table></blockquote>The minimum limit of <b>val</b>. </div></div><div class=CToolTip id="tt30"><div class=CProperty><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">int max_val</td></tr></table></blockquote>The maximum limit of <b>val</b>. </div></div><div class=CToolTip id="tt31"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>function new(</td><td class="PType  prettyprint " nowrap>int&nbsp;</td><td class="PParameter  prettyprint " nowrap>default_val</td><td class="PDefaultValuePrefix  prettyprint ">&nbsp;=&nbsp;</td><td class="PDefaultValue  prettyprint " width=100%> 0,</td></tr><tr><td></td><td class="PType  prettyprint " nowrap>int&nbsp;</td><td class="PParameter  prettyprint " nowrap>min_val</td><td class="PDefaultValuePrefix  prettyprint ">&nbsp;=&nbsp;</td><td class="PDefaultValue  prettyprint " width=100%> 0,</td></tr><tr><td></td><td class="PType  prettyprint " nowrap>int&nbsp;</td><td class="PParameter  prettyprint " nowrap>max_val</td><td class="PDefaultValuePrefix  prettyprint ">&nbsp;=&nbsp;</td><td class="PDefaultValue  prettyprint " width=100%> 10_000_000</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote>Create a random number object.</div></div><!--END_ND_TOOLTIPS-->

<script language=JavaScript><!--
if (browserType) {if (browserVer) {document.write("</div>"); }document.write("</div>");}// --></script></body></html>